class Solution(object):
    def reverseVowels(self, s):
        """
        :type s: str
        :rtype: str
        """
        left_index = 0
        right_index = len(s) - 1
        out = list(s)
        state = 0
        yuanyin = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
        while left_index < right_index:
            if state == 0:
                if s[left_index] in yuanyin:
                    state = 1
                else:
                    left_index += 1
            else:
                if s[right_index] in yuanyin:
                    out[left_index], out[right_index] = out[right_index], out[left_index]
                    state = 0
                    left_index += 1
                    right_index -= 1
                else:
                    right_index -= 1
        return ''.join(out)

data = Solution()
s = "leetcode"
print(data.reverseVowels(s))
